home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 11 April 1997
- // Author: ms
- //
- // Description:
- // Initialize the option values for duplicate curve menu item.
- //
- // Input Arguments:
- // int action
- // 0 - just execute the duplicate curve operation
- // 1 - show the option box dialog
- // 2 - drag to shelf
- //
- // Return Value:
- // None.
- //
-
- proc setOptionVars(int $forceFactorySettings)
- {
- if ($forceFactorySettings || !`optionVar -exists duplicateCurveLocal`) {
- optionVar -intValue duplicateCurveLocal 0;
- }
- if ($forceFactorySettings || !`optionVar -exists duplicateCurveIsoparms`) {
- optionVar -intValue duplicateCurveIsoparms 2;
- }
- }
-
- //
- // Procedure Name:
- // duplicateCurveSetup
- //
- // Description:
- // Update the state of the option box UI to reflect the duplicate curve
- // option values.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI.
- // Required so that UI object names can be
- // successfully resolved.
- //
- // forceFactorySettings - Whether the option values should be set to
- // default values.
- //
- // Return Value:
- // None.
- //
- global proc duplicateCurveSetup( string $parent,
- int $forceFactorySettings,
- string $goToTool )
- {
- // Retrieve the option settings
- //
- setOptionVars($forceFactorySettings);
- duplicateCurveToolSetup( $forceFactorySettings, $goToTool );
- setParent $parent;
-
- // Query the optionVar's and set the values into the controls.
-
- int $local = `optionVar -query duplicateCurveLocal`;
- checkBoxGrp -edit -v1 $local localButton;
-
- int $iso = `optionVar -query duplicateCurveIsoparms`;
- radioButtonGrp -edit -select ($iso+1) isoparmsButton;
-
- if( "" != $goToTool ) {
- checkBoxGrp -e -v1 `scriptCtx -q -exitUponCompletion $goToTool`
- scriptToolExtraWidget;
- checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool`
- scriptToolExtraWidget;
- }
- }
-
- //
- // Procedure Name:
- // duplicateCurveCallback
- //
- // Description:
- // Update the option values with the current state of the option box UI.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI. Required so
- // that UI object names can be successfully resolved.
- //
- // doIt - Whether the command should execute.
- //
- // Return Value:
- // None.
- //
- global proc duplicateCurveCallback( string $parent,
- int $doIt,
- string $goToTool )
- {
- if( "" != $goToTool ) {
- optionVar -iv duplicateCurveEuc `scriptCtx -q -euc $goToTool`;
- optionVar -iv duplicateCurveLac `scriptCtx -q -lac $goToTool`;
- }
- setParent $parent;
-
- // Set the optionVar's from the control values, and then
- // perform the command.
-
- int $local = `checkBoxGrp -query -v1 localButton`;
- optionVar -intValue duplicateCurveLocal $local;
-
- int $iso = `radioButtonGrp -query -select isoparmsButton`;
- optionVar -intValue duplicateCurveIsoparms ($iso-1);
-
- if( 1 == $doIt ) {
- performDuplicateCurve( 0, $goToTool );
- string $tmpCmd = "performDuplicateCurve( 0, \"" + $goToTool + "\")";
- addToRecentCommandQueue $tmpCmd "Duplicate Surface Curves";
- }
- else if( $doIt ) {
- setToolTo $goToTool;
- }
- }
-
- //
- // Procedure Name:
- // duplicateCurveUI
- //
- // Description:
- // Fill the contents of the option box for duplicate curve command.
- //
- // Input Arguments:
- // The name of the parent layout.
- //
- // Return Value:
- // None.
- //
- proc duplicateCurveUI(string $parent, string $goToTool)
- {
- setParent $parent;
-
- checkBoxGrp -ncb 1
- -label ""
- -label1 "Group With Original"
- localButton;
-
- radioButtonGrp -nrb 3
- -label "Visible Surface Isoparms"
- -label1 "U"
- -label2 "V"
- -label3 "Both"
- isoparmsButton;
-
- if( "" != $goToTool ) {
- separator;
- checkBoxGrp -ncb 2 -l "Tool Behavior"
- -l1 "Exit on Completion"
- -v1 on
- -on1 ("scriptCtx -e -euc true " + $goToTool)
- -of1 ("scriptCtx -e -euc false " + $goToTool)
-
- -l2 "Auto Completion"
- -v2 on
- -on2 ("scriptCtx -e -lac true " + $goToTool)
- -of2 ("scriptCtx -e -lac false " + $goToTool)
- scriptToolExtraWidget;
-
- radioButtonGrp -e -enable false isoparmsButton;
- }
- }
-
- //
- // Procedure Name:
- // duplicateCurveOptions
- //
- // Description:
- // Construct the option box UI. Involves accessing the standard option
- // box and customizing the UI accordingly.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc duplicateCurveOptions( int $inTheTool, string $goToTool )
- {
- // Name of the command for this option box.
- //
- string $commandName = "duplicateCurve";
-
- // Build the option box actions.
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- // The value returned is the name of the layout to be used as
- // the parent for the option box UI.
- //
- global string $gOptionBoxActionToolItem;
- $gOptionBoxActionToolItem = "modelWithToolDuplCurve";
- global string $gOptionBoxActionToolItemCB;
- $gOptionBoxActionToolItemCB = "duplicateCurveToolScript 3";
-
- string $layout = getOptionBox();
- setParent $layout;
-
- // Pass the command name to the option box.
- //
- // Any default option box behavior based on the command name is set
- // up with this call.
- //
- setOptionBoxCommandName($commandName);
-
- // Activate the default UI template so that the layout of this
- // option box is consistent with the layout of the rest of the
- // application.
- //
- setUITemplate -pushTemplate DefaultTemplate;
-
- // Turn on the wait cursor.
- //
- waitCursor -state 1;
-
- // RECOMMENDATION: Place the UI in a scroll layout. If the
- // option box window is ever resized such that it's entire
- // contents is not visible then the scroll bars provided by the
- // scroll layout will allow the user to access the hidden UI.
- //
- tabLayout -scr true -tv false;
-
- string $parent = `columnLayout -adjustableColumn 1`;
-
- // Create the UI for the tab that is initially visible.
- //
- duplicateCurveUI($parent, $goToTool);
-
- // Turn off the wait cursor.
- //
- waitCursor -state 0;
-
- // Deactivate the default UI template.
- //
- setUITemplate -popTemplate;
-
- // 'Duplicate' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- if( $inTheTool ) {
- button -edit
- -label "Duplicate Tool"
- -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"")
- $applyBtn;
- }
- else {
- button -edit
- -label "Duplicate"
- -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"")
- $applyBtn;
- }
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " 0 \"" +
- $goToTool + "\"; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"")
- $resetBtn;
-
- // Set the option box title.
- //
- if( $inTheTool ) {
- setOptionBoxTitle("Duplicate Surface Curves Tool Options");
- }
- else {
- setOptionBoxTitle("Duplicate Surface Curves Options");
- }
-
- // Customize the 'Help' menu item text.
- //
- setOptionBoxHelpTag( "DuplicateSurfaceCurves" );
-
- // Set the current values of the option box.
- //
- eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\"");
-
- // Show the option box.
- //
- showOptionBox();
- }
-
- //
- // Procedure Name:
- // duplicateCurveHelp
- //
- // Description:
- // Returns a short description about the duplicate curve command.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // string.
- //
- proc string attachHelp()
- {
- return
- " Command: Duplicate Curve - make a 3D curve from a 2D curve.\n" +
- "Selection: curve on surface, surface isoparam, trimmed surface boundary.";
- }
-
- //
- // Procedure Name:
- // assembleCmd
- //
- // Description:
- // Construct the duplicate curve command that will apply the option
- // box values.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // The duplicate curve command string.
- //
- proc string assembleCmd()
- {
- setOptionVars(false);
-
- // query the settings for cmd(s).
- //
- string $version = "\"2\"";
- int $doHistory = `constructionHistory -q -tgl`;
- int $curveRangePartial = `optionVar -q duplicateCurveRangePartial`;
- int $local = `optionVar -q duplicateCurveLocal`;
- int $iso = `optionVar -q duplicateCurveIsoparms`;
-
- $cmd = "duplicateCurvePresetArgList" ;
- $cmd = $cmd + "( ";
- $cmd = $cmd + $version;
- $cmd = $cmd + ", {\"" ;
- $cmd = $cmd + $doHistory ;
- $cmd = $cmd + "\",\"" ;
- $cmd = $cmd + $curveRangePartial ;
- $cmd = $cmd + "\",\"" ;
- $cmd = $cmd + $local ;
- $cmd = $cmd + "\",\"" ;
- $cmd = $cmd + $iso ;
- $cmd = $cmd + "\"} )" ;
-
- return $cmd ;
- }
-
- global proc string performDuplicateCurve(int $action, string $goToTool)
- //
- // Description:
- // Perform the duplicate curve command using the appropriate
- // option values. This procedure will also show the option box
- // window if necessary as well as construct the command string
- // that will invoke the duplicate curve command with the current
- // option box values.
- //
- // Input Arguments:
- // $action = 0 ==>do the command.
- // $action = 1 ==>show option box.
- // $action = 2 ==>drag to shelf.
- // $action = 3 ==>set the button to enter the tool
- //
- // Return Value:
- // The duplicate curve command string.
- //
- {
- int $inTheTool = false;
- if( 3 == $action ) {
- $action = 1;
- $inTheTool = true;
- }
-
- string $cmd = "";
- switch ($action) {
- case 0:
- setOptionVars(false);
- $cmd = `assembleCmd`;
- eval($cmd);
- break;
- case 1:
- duplicateCurveOptions( $inTheTool, $goToTool );
- break;
- case 2:
- setOptionVars(false);
- $cmd = `assembleCmd`;
- break;
- }
- return $cmd;
- }
-